package cn.bluedot.controller;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.bluedot.model.Pig;
import cn.bluedot.model.VaccinationSettingInfo;
import cn.bluedot.service.VaccinationSettingService;

/**
 * 接种疫苗设置conntroller
 * 
 * @author hxp 2019年4月18日 下午7:31:11
 */
@Controller
public class VaccinationSettingController {
    private static final Logger logger = Logger.getLogger(VaccinationSettingController.class);
    @Autowired
    VaccinationSettingService vaccinationSettingService;
    
    /**
     * 查询所要进行疫苗接种的猪
     * @return 猪的集合
     */
    @RequestMapping("/vaccinationAllPig")
    public  List<Pig> queryAllPig(){
       List<Pig> list;
       list = vaccinationSettingService.queryAllPig();
       logger.debug(list);
       return list; 
    }
    /**
     * 按所在猪栏查询要接种的猪信息
     * @return  猪的集合
     */
    @RequestMapping("/vaccinationPigByHogcote")
    public List<Pig>  queryPigByHogcote(String hogcote){
        logger.debug("hogcote:"+hogcote);
        List<Pig> list = vaccinationSettingService.queryPigByHogcote(hogcote);
        logger.debug(list);
        return list;
    }
    
    /**
     * 按猪种类查询要接种的猪信息
     * @return  猪的集合
     */
    @RequestMapping("/vaccinationPigBypigType")
    public List<Pig>  queryPigByPigType(String pigType){
        List<Pig> list = vaccinationSettingService.queryPigByPigType(pigType);
        logger.debug(list);
        return list;
    }
    
    /**
     * 按所在猪栏和猪种查询要接种的猪信息
     * @return  猪的集合
     */
    @RequestMapping("/vaccinationPigByHogcoteType")
    public List<Pig>  queryPigByHogcoteAndPigType(String hogcote, String pigType){
        logger.debug("hogcote:"+hogcote+"     pigType"+pigType);
        List<Pig> list = vaccinationSettingService.queryPigByHogcoteAndPigType(hogcote, pigType);
        logger.debug(list);
        return list;
    }
    /**
     * 批量设置接种猪只信息
     * @param info  设置提醒参数
     * @param pigList  接种猪只耳标信息集合
     * @return
     */
    @RequestMapping("/vaccineSetting")
    public void  batchSaveVaccinationSettingInfo(VaccinationSettingInfo info, ArrayList<String> pigList) { 
        //将数据库 的接种状态设置默认值为未接种
        vaccinationSettingService.batchSaveVaccinationSettingInfo(info, pigList);       
    }
    
    //TODO 接种提醒功能尚未实现
}
